def brac(text):
    while '()' in text or '[]' in text or '{}' in text:
        text=text.replace('()','')
        text=text.replace('[]','')
        text=text.replace('{}','')
    return not text
print(brac('(((2*x+38-(12*x+17)*3)()'))
